package swu.myt;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class UserCheck {
	
	public static boolean findUser(String name,String pass) throws SQLException {

			String Sql = "select * from `user_login` where user_name='"+name+"'";
		
			System.out.println(DBUtils.getUser(Sql).getName());
			
			if(DBUtils.getUser(Sql)==null) {
				System.out.println("is null");
				return false;
				
			}
			else if(DBUtils.getUser(Sql).getPass().equals(pass)) {
				System.out.println("is right");
				return true;
			}
			else {
				return false;
			}
							
	}
	
	public static boolean UserNotIn(String name) throws SQLException {

		String Sql = "select * from `user_login` where user_name='"+name+"'";
		System.out.println(name);
		System.out.println("this is usercheck");
		System.out.println(DBUtils.getUser(Sql).getName());
						
		if(DBUtils.getUser(Sql).getName()==null) {
			System.out.println("name is null");
			return true;//数据库没有相同名字，则可以注册
			
		}
		else {
			
			return false;//有相同名字就不可以注册
		}
		
	}

}
